import java.util.Scanner; 
import com.jcraft.jsch.*; 
public class VyattaSSH extends Thread 
{ 
	static Scanner sc=new Scanner(System.in); 
	static Session session; 
	static Channel channel; 
	@SuppressWarnings("unused")
	VyattaSSH() 
	{ 
        try 
        { 
        	JSch jsch=new JSch();  		
      		LoginDetails ld=new LoginDetails();
       		session=jsch.getSession(ld.getUser(),ld.getHost(), 22); 
    		session.setPassword(ld.getPwd()); 
      		UserInfo ui = new MyUserInfo() 
 	        { 
 	        	public boolean promptYesNo(String message) 
 	        	{   		 
 	        		System.out.println("enter 0 for exit 1 for continue"); 
 	        		int foo=sc.nextInt(); 
 	        		return foo==1; 
 	        	} 
 	        }; 
 	        session.setUserInfo(ui); 
      		session.connect(30000);   
      	    channel=session.openChannel("shell"); 
      	    channel.connect(3*1000);  	  
      	    VyattaTerminalOutput vteriminal = new VyattaTerminalOutput(channel.getInputStream(),channel.getOutputStream()); 
      	    VyattaCommands vc=new VyattaCommands(vteriminal);   	    
      	 } 
         catch(Exception e) 
         { 
        	e.printStackTrace(); 
         } 
	} 
	public static abstract class MyUserInfo implements UserInfo, UIKeyboardInteractive 
	{ 
   	   public String getPassword() 
   	   { 
   		   return null; 
   	   } 
       public boolean promptYesNo(String str) 
   	   { 
   		   return false; 
   	   } 
   	   public String getPassphrase() 
   	   { 
   		   return null; 
   	   } 
       public boolean promptPassphrase(String message) 
   	   { 
   		   return false; 
   	   } 
       public boolean promptPassword(String message) 
       { 
   		   return false; 
       } 
       public void showMessage(String message) 
       { 
     	 
       } 
       public String[] promptKeyboardInteractive(String destination,String name,String instruction, String[] prompt,boolean[] echo) 
       { 
               return null; 
       } 
	} 
}
